  <div id="page_message" class="page_mess_animate page_mess_error">
    
  </div>
<div class="from_main wrap">
    <div class="panel panel-user">
        <div class="panel-heading">账户注册</div>
        <div class="panel-body">
            <form id="regform" class="form-horizontal" role="form" action="<?php echo url_for('user/register'); ?>" method="POST">
                <ul class="login_ul">
                    <li>
                        <label class="col-xs-2 control-label">用户名：</label>
                        <div class="col-xs-9">
                            <!--<input type="text" maxlength="15"  class="form-control" id="username" name="UserName" placeholder="请输入用户名">-->
                            <input type="text" maxlength="15"  class="form-control" id="username" name="UserName" placeholder="请输入用户名">
                            <?php if ($sf_user->hasFlash('username_error')): ?>
                            <label for="username" class="errormsg"><?php echo $sf_user->getFlash('username_error') ?></label>
                            <?php endif;?>
                        </div>
                    </li>
                    <li>
                        <label class="col-xs-2 control-label">密码：</label>
                        <div class="col-xs-9">
                            <!--<input type="password" maxlength="16" class="form-control" id="password" name="Password" placeholder="请输入密码">-->
                            <input type="password" maxlength="16" class="form-control" id="password" name="Password" placeholder="请输入密码">
                            <?php if ($sf_user->hasFlash('password_error')): ?>
                            <label for="password" class="errormsg"><?php echo $sf_user->getFlash('password_error') ?></label>
                            <?php endif;?>
                        </div>
                    </li>
                    <li>
                        <label class="col-xs-2 control-label">手机号：</label>
                        <div class="col-xs-9">
                            <!--<input type="text"  maxlength="11"  class="form-control" id="mobile" name="Mobile" placeholder="请输入手机号码">-->
                            <input type="text"  maxlength="11"  class="form-control" id="mobile" name="Mobile" placeholder="请输入手机号码">
                             <?php if ($sf_user->hasFlash('mobile_error')): ?>
                            <label for="mobile" class="errormsg"><?php echo $sf_user->getFlash('mobile_error') ?></label>
                            <?php endif;?>
                        </div>
                    </li>
                    <li>
                        <label class="col-xs-3 control-label">手机验证码：</label>
                        <div class="col-xs-8">
<!--                            <input type="text" class="form-control" id="auth" name="auth">
                            <input type="button" class="btn btn-default" id="getauthcode" value="获取验证码" style="font-size: 16px;" />-->
                            <input type="text" class="form-control" id="auth" name="auth">
                            <input type="button" class="btn btn-default" id="getauthcode" value="获取验证码" style="font-size: 16px;" />
                            <?php if ($sf_user->hasFlash('mobile_error')): ?>
                            <label for="mobile" class="errormsg"><?php echo $sf_user->getFlash('mobile_error') ?></label>
                            <?php endif;?>
                            <input name="reg_from" value="<?php echo $sf_request->getReferer()?>" type="hidden">
                        </div>
                    </li>
                    <li>
                        <label class="col-xs-2 control-label">验证码：</label>
                        <div class="col-xs-9">
			    <div class="input-group">
                                <input type="text" class="form-control ft-l" maxlength="5" id="auth" name="validatorCode">
                                <span class="input-group-addon ft-l">
                                    <img src="<?php echo url_for('user/captcha') .'?sid='.md5(time()) ?>" id="authimg" onclick="$('#authimg').attr('src','<?php echo url_for('user/captcha') ?>?sid=' + Math.random());return false;"/></span>
                            </div>
                            <?php if ($sf_user->hasFlash('code_error')): ?>
                            <label for="code" class="errormsg"><?php echo $sf_user->getFlash('code_error') ?></label>
                            <?php endif;?>
                        </div>
                    </li>
                    <li>
                        <label class="col-xs-2 control-label"></label>
                        <div class="col-xs-9">
                            <div class="checkbox">
                                <label>
                                    <input class="checkIE" type="checkbox" value="1" checked="checked" name="aeccpet" />
                                    我已阅读并同意<a href="<?php echo url_for('default/protocol'); ?>" target="_blank">《微美贷网站服务协议》</a><br/>和<a href="http://vmstatic.vmdai.com/images/%E5%BE%AE%E7%BE%8E%E8%B4%B7%E5%80%9F%E6%AC%BE%E5%90%88%E5%90%8C.pdf" target="_blank">《微美贷借款合同》</a>
                                </label>
                            </div>
                        </div>
                    </li>
                    <li>
                        <label class="col-xs-2 control-label"></label>
                        <div class="col-xs-9">
                            <input type="submit" class="btn btn-primary" value="注册" />
                        </div>
                    </li>
                </ul>
            </form>
            <span class="nouser">已有账号？<a href="<?php echo url_for('user/login'); ?>">立即登录</a></span>
        </div>
    </div>
</div>

<script type="text/javascript">
    $(function () {
        $(".main").addClass("projectlist");
        if ($("#errormsg").text().length > 0) {
            $.scojs_message($("#errormsg").text(), $.scojs_message.TYPE_ERROR);
        }
    })
</script>
<script type="text/javascript">
    $("#getauthcode").on('click', function () {
        var mobile = $("#mobile").val();
        var _this = this;
	
        if(mobile.length < 11){
            alert('手机号码长度错误！');
            return false;
        }
        
        $.ajax({
             type: "POST",
             url: "<?php echo url_for('user/create_code'); ?>",
             data: "mobile=" + mobile,
             dataType:"json",
             success: function(data){
                
                 if(data.result == "error"){
                    $("#page_message").html(data.message).show().fadeOut(2000);
		    return false;
                }
		
		time(_this);
             }   
        });
    })
</script>

    <script type="text/javascript">  
    var wait=60;  
    function time(o) {  
            if (wait == 0) {  
                o.removeAttribute("disabled");            
                o.value="获取验证码";  
                wait = 60;  
            } else {  
                o.setAttribute("disabled", true);  
                o.value="重新发送(" + wait + ")";  
                wait--;  
                setTimeout(function() {  
                    time(o)  
                },  
                1000)  
            }  
        }  
//    document.getElementById("getauthcode").onclick=function(){
//        mobile = $("#mobile").val();
//        if(mobile.length <= 0) return false;
//        
//
//         var   reg   = /^(13[0-9]|14[57]|15[0-35-9]|18[0-9]|17[0])[0-9]{8}$/;  
//         if(!reg.test(mobile)){
//             return false;
//         } 
//        
////        time(this);
//    }  
    </script>  
